package com.monitor.zk.zookeeper.core;

import cn.hutool.core.io.resource.ClassPathResource;
import core.ParamsContext;
import core.annotation.BeforeStart;
import core.annotation.StartHandle;
import core.scan.ScanXmlConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@BeforeStart
@Component
public class StartInitXml implements StartHandle {

    private final String scanXmlPath = new ClassPathResource("classPath:xml").getPath();

    @Override
    public void start(ParamsContext paramsContext) {
        log.info("初始化xml文件");
        try {
            ScanXmlConfig scanXmlConfig = ScanXmlConfig.newInScanXmlConfig();
            scanXmlConfig.scanResourceByPackage(scanXmlPath);
        } catch (Exception e) {
            log.error("初始化xml失败，原因：{}",e.getMessage());
        }
        log.info("初始化xml文件完成");
    }
}
